package com.reservation.controller.staff;

import com.reservation.dto.staff.FinishMaintenanceDTO;
import com.reservation.result.Result;
import com.reservation.service.StaffService;
import com.reservation.vo.staff.MaintenanceRoomVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 员工维护会议室相关API
 */
@Api(tags = "员工会议室维护接口")
@RestController
@RequestMapping("/api/staff")
@Slf4j
public class MaintenanceController {

    @Autowired
    private StaffService staffService;

    /**
     * 获取维护中的会议室列表
     *
     * @return 维护中的会议室列表
     */
    @PostMapping("/getMaintenanceList")
    @ApiOperation("获取维护中的会议室列表")
    public Result<List<MaintenanceRoomVO>> getMaintenanceList() {
        log.info("获取维护中的会议室列表");
        List<MaintenanceRoomVO> list = staffService.getMaintenanceList();
        return Result.success(list);
    }

    /**
     * 完成会议室维护
     *
     * @param finishMaintenanceDTO 包含会议室ID的DTO
     * @return 操作结果
     */
    @PostMapping("/finishMaintenance")
    @ApiOperation("完成会议室维护")
    public Result<String> finishMaintenance(@Valid @RequestBody FinishMaintenanceDTO finishMaintenanceDTO) {
        log.info("完成会议室维护，会议室ID: {}", finishMaintenanceDTO.getId());
        return staffService.finishMaintenance(finishMaintenanceDTO.getId()) ?
            Result.success("会议室维护已完成") :
            Result.error("操作失败，请重试");
    }
}
